<template>
  <div class="introduction-card" :class="{ 'has-image': image }">
    <!-- 图片部分 -->
    <div v-if="image" class="image-container">
      <img :src="image" :alt="title" />
    </div>

    <!-- 文字内容部分 -->
    <div class="content">
      <!-- 标题 -->
      <h2 v-if="title" class="title">{{ title }}</h2>

      <!-- 内容 -->
      <div v-if="content" class="text" v-html="content"></div>

      <!-- 按钮（可选） -->
      <div v-if="buttonText && buttonLink" class="button-container">
        <a :href="buttonLink" class="button" target="_blank">{{ buttonText }}</a>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "IntroductionCard",
  props: {
    title: {
      type: String,
      default: "",
    },
    content: {
      type: String,
      default: "",
    },
    image: {
      type: String,
      default: null,
    },
    buttonText: {
      type: String,
      default: null,
    },
    buttonLink: {
      type: String,
      default: null,
    },
  },
};
</script>

<style scoped>
.introduction-card {
  display: flex;
  flex-direction: column;
  font-size: 16px;
  padding: 10px;
  border-radius: 8px;
}

.introduction-card.has-image {
  flex-direction: row;
}

.image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.content {
  flex: 2;
  display: flex;
  flex-direction: column;
  font-size: 16px;
}

.title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #FFFFFF;
}

.text {
  font-size: 15px;
  color: white;
  line-height: 1.6;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
  /* 超出几行省略 */
  overflow: hidden;
}

.button-container {
  text-align: right;
}

.button {
  display: inline-block;
  padding: 8px 16px;
  background-color: #007bff;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 1rem;
  transition: background-color 0.3s;
}

.button:hover {
  background-color: #0056b3;
}
</style>
